
import Head from 'next/head'

<Head>
  <script>
    {
      `(function() {
         var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e60fb290e204e04c5cb6f79b0ac1e697";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
       })();`
    }
  </script>
</Head>

![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif)





Weaviate混合搜索[#](#weaviate-hybrid-search "Permalink to this headline")
=====================================================================

本教程演示了如何使用[Weaviate混合搜索](https://weaviate.io/blog/hybrid-search-explained)作为LangChain检索器。

```python
import weaviate
import os

WEAVIATE_URL = "..."
client = weaviate.Client(
    url=WEAVIATE_URL,
)

```

```python
from langchain.retrievers.weaviate_hybrid_search import WeaviateHybridSearchRetriever
from langchain.schema import Document

```

```python
retriever = WeaviateHybridSearchRetriever(client, index_name="LangChain", text_key="text")

```

```python
docs = [Document(page_content="foo")]

```

```python
retriever.add_documents(docs)

```

```python
['3f79d151-fb84-44cf-85e0-8682bfe145e0']

```

```python
retriever.get_relevant_documents("foo")

```

```python
[Document(page_content='foo', metadata={})]

```

